<?php
class BuildingMoveAction extends SzAbstractAction
{
    protected $paramTypes = array(
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_STRING,
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_ARRAY,
        SzAbstractAction::TYPE_ARRAY
    );

    /**
     * Move a decoration.
     *
     * @param int $userId
     * @param string $originGridId
     * @param int $gridLayer
     * @param array $targetGridIds
     * @param array $targetBlockIds
     * @return SzResponse
     */
    public function execute($userId, $originGridId, $gridLayer, $targetGridIds, $targetBlockIds)
    {
        /**
         * @var GroundVo $originGround
         * @var GroundVo $targetGround
         */
        list($originGround, $targetGround) = BuildingService::get()->move($userId, $originGridId, $gridLayer, $targetGridIds, $targetBlockIds);
        return $this->buildResponse(array(
            'originGround' => $originGround->toArray(),
            'targetGround' => $targetGround->toArray()
        ));
    }
}